package com.sqly.doc.menu.grjbxx;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Environment;
import android.support.annotation.IdRes;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.animation.Animation;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.cazaea.sweetalert.SweetAlertDialog;
import com.ihidea.multilinechooselib.MultiLineChooseLayout;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.adapter.CommonAdapter;
import com.sqly.doc.adapter.ViewHolder;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.menu.fwjl.fwjl_add;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.pojo.Xx;
import com.sqly.doc.util.Constants;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import org.litepal.crud.DataSupport;

import java.io.File;
import java.io.FileNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import butterknife.Bind;
import butterknife.ButterKnife;
import cxy.com.validate.IValidateResult;
import cxy.com.validate.Validate;
import cxy.com.validate.annotation.Index;
import cxy.com.validate.annotation.MaxLength;
import cxy.com.validate.annotation.NotNull;
import cxy.com.validate.annotation.RE;
import cz.msebera.android.httpclient.Header;

//import cn.pedant.SweetAlert.SweetAlertDialog;

/**
 * Created by Administrator on
 */

public class jm_info_add extends MyBaseActivity {
    JuMin obj;
    Context con = jm_info_add.this;
    private CustomDatePicker customDatePicker;
    //页面的容器
    LinearLayout t1, t2, t3, t4, t5, t6, dahll,ll_xzqh;
    ImageView i1, i2, i3, i4, i5, i6;
    LinearLayout s1, s2, s3, s4, s5, s6;
    LinearLayout ll_swrq;

    //基础信息
    TextView SCJDRQ;//建档日期
    @Bind(R.id.xzqh)TextView xzqh;//行政区划
    @Bind(R.id.xzqhname)TextView xzqhname;//行政区划
    @Index(1)@NotNull(msg = "姓名不能为空")@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.xm)EditText XINGMING;
    @Index(2)@NotNull(msg = "身份证不能为空")@RE(re = Constants.SFZH_REGEXP, msg = "请输入正确身份证号")@Bind(R.id.sfzh)EditText SFZH;
    @Index(3)@NotNull(msg = "出生日期不能为空")@Bind(R.id.csrq)TextView CSRQ;
    @Bind(R.id.dah)TextView jkdah;@Bind(R.id.swrq)TextView SWRQ;
    @Index(4)@RE(re = RE.only_number, msg = "仅可输入数字")@Bind(R.id.nl)EditText NIANLING;
    @Index(5)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.gzdw)EditText GZDW;
    @Index(6)@RE(re = Constants.LXDH_All_REGEXP, msg = "请输入正确的联系电话")@Bind(R.id.LXDH)EditText LXDH;
    @Index(7)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.lxrxm)EditText LXRXM;
    @Index(8)@RE(re = Constants.LXDH_All_REGEXP, msg = "请输入正确的联系电话")@Bind(R.id.lxrdh)EditText LXRDH;
    @Index(9)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.hjdz)EditText HJDZ;
    @Index(10)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.mz)EditText MINZU;

    @Bind(R.id.xb)RadioGroup XINGBIE;
    @Bind(R.id.czlx)RadioGroup CZLX;
    @Bind(R.id.xx)RadioGroup XUEXING;
    @Bind(R.id.rh)RadioGroup XUEXINGRH;
    @Bind(R.id.rystatus)RadioGroup RYSTATUS;

    String XINGBIEs = "1", CZLXs = "1", XUEXINGs = "1", xuexingrh = "1";//1男2女9未说明0未知,1户籍2非户籍-1A2B3O4AB-1否2是3不详-1否2是
    //文化职业
    @Bind(R.id.whcd)Spinner whcd;
    @Bind(R.id.zy)Spinner zhiye;
    @Bind(R.id.hyzk)Spinner hunyin;
    String whcds = "", zhiyes = "", hunyins = "";
    //医疗支付方式
    CheckBox type1, type2, type3, type4, type5, type6, type7;
    @Index(11)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.ybkh1)EditText  ybkh1;
    @Index(12)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.ybkh2)EditText ybkh2;
    @Index(13)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.ybkh3)EditText ybkh3;
    @Index(14)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.qt)EditText zffsqt;
    @Index(15)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.jws_qt)EditText JWSJBQT;
    int qt_enable = 0;//其他选项的可用性,0代表没有其他之外的选项选中
    String YLZFSF = "";
    //过敏史等信息
    MultiLineChooseLayout ywgms, bls, jws;
    private List<String> ywgmsdata = new ArrayList<>();
    private List<String> blsdata = new ArrayList<>();
    private List<String> jwsdata = new ArrayList<>();
    @Index(16)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.gms_qt)EditText gms_qt;
    //暴露史
    CheckBox c5, c6, c7, c8;
    //既往史
    CheckBox jb1, jb2, jb3, jb4, jb5, jb6, jb7, jb8, jb9, jb10, jb11, jb12, jb13;
    EditText jbqt;
    TextView gxqqzrq, tnbqzrq, gxbqzrq, mxzsxfjbqzrq, exzlqzrq, nczqzrq, jsbqzrq, jhbqzrq, gyqzrq, crbqzrq, zybqzrq;
    //手术
    RadioGroup ss;
    @Index(17)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.ssmc1)EditText ssmc1;
    @Index(18)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.ssmc2)EditText ssmc2;
    TextView sssj1, sssj2;
    RadioGroup ws;
    @Index(19)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.wsmc1)EditText wsmc1;
    @Index(20)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.wsmc2)EditText wsmc2;
    TextView wssj1, wssj2;
    RadioGroup sx;
    @Index(21)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.sxyy1)EditText sxyy1;
    @Index(22)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.sxyy2)EditText sxyy2;
    TextView sxsj1, sxsj2;
    //家族史
    MultiLineChooseLayout fq, mq, xdjm, zn, cjqk, guanli;
    private List<String> fqdata = new ArrayList<>();
    private List<String> mqdata = new ArrayList<>();
    private List<String> xdjmdata = new ArrayList<>();
    private List<String> zndata = new ArrayList<>();
    private List<String> cjqkdata = new ArrayList<>();
    private List<String> guanlidata = new ArrayList<>();
    @Index(23)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.fqqt)EditText  fqqt;
    @Index(24)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.mqqt)EditText mqqt;
    @Index(25)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.xdjmqt)EditText xdjmqt;
    @Index(26)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.znqt)EditText znqt;
    @Index(27)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.ycbmc)EditText ycbmc;
    RadioGroup ycbs;
    @Index(28)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.cjqkqt)EditText  cjqt;
    //生活环境
    @Index(29)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.hzxm)EditText  hzxm;
    @Index(30)@RE(re = Constants.SFZH_REGEXP, msg = "请输入正确户主身份证号")@Bind(R.id.hzsfzh)EditText hzsfzh;
    @Index(31)@RE(re = RE.only_number, msg = "仅可输入数字")@Bind(R.id.jtrks)EditText  jtrks;
    @Index(32)@MaxLength(length = 20, msg = "最大长度为20个字符")@Bind(R.id.jtjg)EditText  jtjg;
    Spinner jzqk, cfpfss, rllx, yinshui, ceshuo, qcl;
    String cfpfsss = "1", rllxs = "1", yinshuis = "1", ceshuos = "1", qcls = "1";
    //标题
    //标题
    TextView title, uname;
    LinearLayout back;
    ImageView qm;
    String picname = "";

    String url = "";
    @Bind(R.id.bddh1)ImageView bddh1;
    @Bind(R.id.bddh2)ImageView bddh2;
    @Index(33)@MaxLength(length = 20, msg = "最大长度为20个字符")
    @Bind(R.id.czdz) EditText czdz;
    String startDate = "1980-01-01 00:00";

    ImageView xcqm;
    String xcqmpic ="";
    ImageView xcpaizhao;
    TextView pz_record_id;
    boolean pzChange = false;

    @Override
    protected void initUI() {
        setContentView(R.layout.jm_info_add);
        ButterKnife.bind(this);
        Validate.reg(this);
        obj = (JuMin) getIntent().getExtras().getSerializable("b");
        if (obj == null)
            obj = new JuMin();
        initCommonView();
        showMenu();
        if(!StringUtils.isEmpty(obj.getImg2())){
            Log.i("obj.getImg2()===", obj.getImg2());
            //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
            ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
        }
    }

    @Override
    protected void initData() {
        Resources res = getResources();
        //文化程度
        String[] whs = res.getStringArray(R.array.whcd);
        List<Xx> xxlist = new ArrayList<Xx>();
        for (int i = 0; i < whs.length; i++) {
            Xx x = new Xx();
            x.setName(whs[i]);
            xxlist.add(x);
        }
        whcd.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, xxlist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getWHCD())) {
            whcd.setSelection(Integer.parseInt(obj.getWHCD()) - 1);
        }
        whcd.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                whcds = (position + 1) + "";
                obj.setWHCD(whcds);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        //居住情况
        String[] jzqkss = res.getStringArray(R.array.jzqk);
        List<Xx> jzlist = new ArrayList<Xx>();
        for (int i = 0; i < jzqkss.length; i++) {
            Xx x = new Xx();
            x.setName(jzqkss[i]);
            jzlist.add(x);
        }
        jzqk.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, jzlist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getJTQKJZQK())) {
            jzqk.setSelection(Integer.parseInt(obj.getJTQKJZQK()) - 1);
        }else{
            jzqk.setSelection(0);
        }
        jzqk.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                obj.setJTQKJZQK((position + 1) + "");
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        //职业信息
        String[] zys = res.getStringArray(R.array.zhiye);
        List<Xx> zylist = new ArrayList<Xx>();
        for (int i = 0; i < zys.length; i++) {
            Xx x = new Xx();
            x.setName(zys[i]);
            zylist.add(x);
        }
        zhiye.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, zylist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getZHIYE())) {
            zhiye.setSelection(Integer.parseInt(obj.getZHIYE()) - 1);
        }
        zhiye.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                zhiyes = position + "";
                obj.setZHIYE(zhiyes);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        //婚姻
        String[] hys = res.getStringArray(R.array.hyzk);
        List<Xx> hylist = new ArrayList<Xx>();
        for (int i = 0; i < hys.length; i++) {
            Xx x = new Xx();
            x.setName(hys[i]);
            hylist.add(x);
        }
        hunyin.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, hylist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getHYQK())) {
            hunyin.setSelection(Integer.parseInt(obj.getHYQK()) - 1);
        }
        hunyin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                hunyins = (position + 1) + "";
                obj.setHYQK(hunyins);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {

        } else if (resultCode == 1) {
            String name = (String) data.getExtras().getString("xzqhname");
            String id = (String) data.getExtras().getString("xzqhid");
            Log.i("id", id);
            xzqhname.setText(name);
            xzqh.setText(id);
        }else if (resultCode == 8) {
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            qm.setImageBitmap(bb);
            picname = CreateBitmap.saveMyBitmap(bb);
            Log.i("图片名称", picname);
        }else if(requestCode == 119){
            String img_record_id = (String) data.getExtras().getString("img_record_id");
            pz_record_id.setText(img_record_id);
            pzChange = true;
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            xcqm.setImageBitmap(bb);
        }
    }

    //实例化基本信息控件
    public void initCommonView() {
        //底部現場照片
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
        }
        xcqm.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                Log.i("img2Arr[1]",img2Arr[1]);
                pz_record_id.setText(img2Arr[1]);
            }
        }
        //标题
        qm = (ImageView) findViewById(R.id.qm);
        if (obj != null && !StringUtils.isEmpty(obj.getQm())) {
            picname = obj.getQm();
            qm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + obj.getQm() + ".jpg"));
        }

        qm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(
                        new Intent(con, WriteActivity.class).putExtra("class",
                                "jm_info_add.class"), 8);
            }
        });
        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);
        title.setText("个人基本信息");
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Validate.check(con, new IValidateResult() {
                    @Override
                    public void onValidateSuccess() {
                        //Toast.makeText(con, "验证成功", Toast.LENGTH_SHORT).show();
                        saveData();
                    }

                    @Override
                    public void onValidateError(String msg, View view) {
                        view.setFocusable(true);
                        //Toast.makeText(con, msg, Toast.LENGTH_SHORT).show();
                        SweetAlertDialogUtil.WarningDialog(con, "提示", msg);
                    }

                    @Override
                    public Animation onValidateErrorAnno() {
//                        return ValidateAnimation.horizontalTranslate();
                        return null;
                    }
                });
            }
        });
        back = (LinearLayout) findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new SweetAlertDialog(con, SweetAlertDialog.WARNING_TYPE)
                        .setTitleText("确定返回")
                        .setContentText("确定不保存返回上个页面?")
                        .setCancelText("取消")
                        .setConfirmText("确定")
                        .showCancelButton(true)
                        .setConfirmClickListener(new SweetAlertDialog.OnSweetClickListener() {
                            @Override
                            public void onClick(SweetAlertDialog sweetAlertDialog) {
                                finish();
                            }
                        })
                        .show();
            }
        });

        //家族史
        fq = (MultiLineChooseLayout) findViewById(R.id.fq);
        fqdata.add("无");
        fqdata.add("高血压");
        fqdata.add("糖尿病");
        fqdata.add("冠心病");
        fqdata.add("慢性阻塞性肺疾病");
        fqdata.add("恶性肿瘤");
        fqdata.add("脑卒中");
        fqdata.add("严重精神障碍");
        fqdata.add("肺结核");
        fqdata.add("肝炎");
        fqdata.add("先天畸形");
        fqdata.add("其他");
        fq.setList(fqdata);
        if (obj != null && !StringUtils.isEmpty(obj.getJZSFQ())) {
            if (obj.getJZSFQ().contains(",")) {
                String[] ss = obj.getJZSFQ().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(null != ss[i] && "0".equals(ss[i])){
                            fq.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else if(null != ss[i] && "A".equals(ss[i])){
                            fq.setIndexItemSelected(9);
                        }else if(null != ss[i] && "B".equals(ss[i])){
                            fq.setIndexItemSelected(10);
                        }else if(null != ss[i] && "C".equals(ss[i])){
                            fq.setIndexItemSelected(11);
                        }else if(null != ss[i] && "D".equals(ss[i])){
                            fq.setIndexItemSelected(12);
                        }else{
                            fq.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if(null != obj.getJZSFQ() && "0".equals(obj.getJZSFQ())){
                    fq.setIndexItemSelected(Integer.parseInt(obj.getJZSFQ()));
                }else if(null != obj.getJZSFQ() && "A".equals(obj.getJZSFQ())){
                    fq.setIndexItemSelected(9);
                }else if(null != obj.getJZSFQ() && "B".equals(obj.getJZSFQ())){
                    fq.setIndexItemSelected(10);
                }else if(null != obj.getJZSFQ() && "C".equals(obj.getJZSFQ())){
                    fq.setIndexItemSelected(11);
                }else if(null != obj.getJZSFQ() && "D".equals(obj.getJZSFQ())){
                    fq.setIndexItemSelected(12);
                }else{
                    if (!StringUtils.isEmpty(obj.getJZSFQ())) {
                        if ("0".equals(obj.getJZSFQ())) {
                            fq.setIndexItemSelected(0);
                        }else {
                            fq.setIndexItemSelected(Integer.parseInt(obj.getJZSFQ()) - 1);
                        }
                    }
                }
            }
        }else {
            fq.setIndexItemSelected(0);
        }
        mq = (MultiLineChooseLayout) findViewById(R.id.mq);
        mqdata.add("无");
        mqdata.add("高血压");
        mqdata.add("糖尿病");
        mqdata.add("冠心病");
        mqdata.add("慢性阻塞性肺疾病");
        mqdata.add("恶性肿瘤");
        mqdata.add("脑卒中");
        mqdata.add("严重精神障碍");
        mqdata.add("肺结核");
        mqdata.add("肝炎");
        mqdata.add("先天畸形");
        mqdata.add("其他");
        mq.setList(mqdata);
        if (obj != null && !StringUtils.isEmpty(obj.getJZSMQ())) {
            if (obj.getJZSMQ().contains(",")) {
                String[] ss = obj.getJZSMQ().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(null != ss[i] && "0".equals(ss[i])){
                            mq.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else if(null != ss[i] && "A".equals(ss[i])){
                            mq.setIndexItemSelected(9);
                        }else if(null != ss[i] && "B".equals(ss[i])){
                            mq.setIndexItemSelected(10);
                        }else if(null != ss[i] && "C".equals(ss[i])){
                            mq.setIndexItemSelected(11);
                        }else if(null != ss[i] && "D".equals(ss[i])){
                            mq.setIndexItemSelected(12);
                        }else{
                            mq.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if(null != obj.getJZSMQ() && "0".equals(obj.getJZSMQ())){
                    mq.setIndexItemSelected(Integer.parseInt(obj.getJZSMQ()));
                }else if(null != obj.getJZSMQ() && "A".equals(obj.getJZSMQ())){
                    mq.setIndexItemSelected(9);
                }else if(null != obj.getJZSMQ() && "B".equals(obj.getJZSMQ())){
                    mq.setIndexItemSelected(10);
                }else if(null != obj.getJZSMQ() && "C".equals(obj.getJZSMQ())){
                    mq.setIndexItemSelected(11);
                }else if(null != obj.getJZSMQ() && "D".equals(obj.getJZSMQ())){
                    mq.setIndexItemSelected(12);
                }else{
                    if (!StringUtils.isEmpty(obj.getJZSMQ())) {
                        if ("0".equals(obj.getJZSMQ())) {
                            mq.setIndexItemSelected(0);
                        }else {
                            mq.setIndexItemSelected(Integer.parseInt(obj.getJZSMQ()) - 1);
                        }
                    }
                }
            }
        }else {
            mq.setIndexItemSelected(0);
        }
        xdjm = (MultiLineChooseLayout) findViewById(R.id.xdjm);
        xdjmdata.add("无");
        xdjmdata.add("高血压");
        xdjmdata.add("糖尿病");
        xdjmdata.add("冠心病");
        xdjmdata.add("慢性阻塞性肺疾病");
        xdjmdata.add("恶性肿瘤");
        xdjmdata.add("脑卒中");
        xdjmdata.add("严重精神障碍");
        xdjmdata.add("肺结核");
        xdjmdata.add("肝炎");
        xdjmdata.add("先天畸形");
        xdjmdata.add("其他");
        xdjm.setList(xdjmdata);
        if (obj != null && !StringUtils.isEmpty(obj.getJZSXDJM())) {
            if (obj.getJZSXDJM().contains(",")) {
                String[] ss = obj.getJZSXDJM().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(null != ss[i] && "0".equals(ss[i])){
                            xdjm.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else if(null != ss[i] && "A".equals(ss[i])){
                            xdjm.setIndexItemSelected(9);
                        }else if(null != ss[i] && "B".equals(ss[i])){
                            xdjm.setIndexItemSelected(10);
                        }else if(null != ss[i] && "C".equals(ss[i])){
                            xdjm.setIndexItemSelected(11);
                        }else if(null != ss[i] && "D".equals(ss[i])){
                            xdjm.setIndexItemSelected(12);
                        }else{
                            xdjm.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if(null != obj.getJZSXDJM() && "0".equals(obj.getJZSXDJM())){
                    xdjm.setIndexItemSelected(Integer.parseInt(obj.getJZSXDJM()));
                }else if(null != obj.getJZSXDJM() && "A".equals(obj.getJZSXDJM())){
                    xdjm.setIndexItemSelected(9);
                }else if(null != obj.getJZSXDJM() && "B".equals(obj.getJZSXDJM())){
                    xdjm.setIndexItemSelected(10);
                }else if(null != obj.getJZSXDJM() && "C".equals(obj.getJZSXDJM())){
                    xdjm.setIndexItemSelected(11);
                }else if(null != obj.getJZSXDJM() && "D".equals(obj.getJZSXDJM())){
                    xdjm.setIndexItemSelected(12);
                }else{
                    if (!StringUtils.isEmpty(obj.getJZSXDJM())) {
                        if ("0".equals(obj.getJZSXDJM())) {
                            xdjm.setIndexItemSelected(0);
                        }else {
                            xdjm.setIndexItemSelected(Integer.parseInt(obj.getJZSXDJM()) - 1);
                        }
                    }
                }
            }
        }else {
            xdjm.setIndexItemSelected(0);
        }
        zn = (MultiLineChooseLayout) findViewById(R.id.zn);
        zndata.add("无");
        zndata.add("高血压");
        zndata.add("糖尿病");
        zndata.add("冠心病");
        zndata.add("慢性阻塞性肺疾病");
        zndata.add("恶性肿瘤");
        zndata.add("脑卒中");
        zndata.add("严重精神障碍");
        zndata.add("肺结核");
        zndata.add("肝炎");
        zndata.add("先天畸形");
        zndata.add("其他");
        zn.setList(zndata);
        if (obj != null && !StringUtils.isEmpty(obj.getJZSZN())) {
            if (obj.getJZSZN().contains(",")) {
                String[] ss = obj.getJZSZN().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(null != ss[i] && "0".equals(ss[i])){
                            zn.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else if(null != ss[i] && "A".equals(ss[i])){
                            zn.setIndexItemSelected(9);
                        }else if(null != ss[i] && "B".equals(ss[i])){
                            zn.setIndexItemSelected(10);
                        }else if(null != ss[i] && "C".equals(ss[i])){
                            zn.setIndexItemSelected(11);
                        }else if(null != ss[i] && "D".equals(ss[i])){
                            zn.setIndexItemSelected(12);
                        }else{
                            zn.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if(null != obj.getJZSZN() && "0".equals(obj.getJZSZN())){
                    zn.setIndexItemSelected(Integer.parseInt(obj.getJZSZN()));
                }else if(null != obj.getJZSZN() && "A".equals(obj.getJZSZN())){
                    zn.setIndexItemSelected(9);
                }else if(null != obj.getJZSZN() && "B".equals(obj.getJZSZN())){
                    zn.setIndexItemSelected(10);
                }else if(null != obj.getJZSZN() && "C".equals(obj.getJZSZN())){
                    zn.setIndexItemSelected(11);
                }else if(null != obj.getJZSZN() && "D".equals(obj.getJZSZN())){
                    zn.setIndexItemSelected(12);
                }else{
                    if (!StringUtils.isEmpty(obj.getJZSZN())) {
                        if ("0".equals(obj.getJZSZN())) {
                            zn.setIndexItemSelected(0);
                        }else {
                            zn.setIndexItemSelected(Integer.parseInt(obj.getJZSZN()) - 1);
                        }
                    }
                }
            }
        }else {
            zn.setIndexItemSelected(0);
        }
        cjqk = (MultiLineChooseLayout) findViewById(R.id.cjqk);
        cjqkdata.add("无残疾");
        cjqkdata.add("视力残疾");
        cjqkdata.add("听力残疾");
        cjqkdata.add("言语残疾");
        cjqkdata.add("肢体残疾");
        cjqkdata.add("智力残疾");
        cjqkdata.add("精神残疾");
        cjqkdata.add("其他");
        cjqk.setList(cjqkdata);
        if (obj != null && !StringUtils.isEmpty(obj.getCJQK())) {
            if (obj.getCJQK().contains(",")) {
                String[] ss = obj.getCJQK().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(null != ss[i] && "0".equals(ss[i])){
                            cjqk.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else{
                            cjqk.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if (!StringUtils.isEmpty(obj.getCJQK())) {
                    if ("0".equals(obj.getCJQK())) {
                        cjqk.setIndexItemSelected(0);
                    }else {
                        cjqk.setIndexItemSelected(Integer.parseInt(obj.getCJQK()) - 1);
                    }
                }
            }
        }else {
            cjqk.setIndexItemSelected(0);
        }

        guanli = (MultiLineChooseLayout) findViewById(R.id.guanli);
        guanlidata.add("65岁以上老年人");
        guanlidata.add("0~6岁儿童");
        guanlidata.add("孕产妇");
        guanlidata.add("高血压");
        guanlidata.add("糖尿病");
        guanlidata.add("严重精神障碍");
        guanlidata.add("冠心病");
        guanlidata.add("脑卒中");
        guanlidata.add("残疾人");
        guanlidata.add("肺结核");
        guanli.setList(guanlidata);
        if (obj != null && !StringUtils.isEmpty(obj.getGUANLI())) {
            if (obj.getGUANLI().contains(",")) {
                String[] ss = obj.getGUANLI().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(null != ss[i] && "LNR".equals(ss[i])){
                            guanli.setIndexItemSelected(0);
                        }else if(null != ss[i] && "ET".equals(ss[i])){
                            guanli.setIndexItemSelected(1);
                        }else if(null != ss[i] && "YCF".equals(ss[i])){
                            guanli.setIndexItemSelected(2);
                        }else if(null != ss[i] && "GXY".equals(ss[i])){
                            guanli.setIndexItemSelected(3);
                        }else if(null != ss[i] && "TNB".equals(ss[i])){
                            guanli.setIndexItemSelected(4);
                        }else if(null != ss[i] && "ZXJSJB".equals(ss[i])){
                            guanli.setIndexItemSelected(5);
                        }else if(null != ss[i] && "GXB".equals(ss[i])){
                            guanli.setIndexItemSelected(6);
                        }else if(null != ss[i] && "NCZ".equals(ss[i])){
                            guanli.setIndexItemSelected(7);
                        }else if(null != ss[i] && "CJR".equals(ss[i])){
                            guanli.setIndexItemSelected(8);
                        }else if(null != ss[i] && "FJH".equals(ss[i])){
                            guanli.setIndexItemSelected(9);
                        }
                    }
                }
            }
        }

        //家庭情况
        if (obj != null && !StringUtils.isEmpty(obj.getJTQKHZ()))
            hzxm.setText(obj.getJTQKHZ());
        if (obj != null && !StringUtils.isEmpty(obj.getJTQKHZSFZH()))
            hzsfzh.setText(obj.getJTQKHZSFZH());

        if (obj != null && !StringUtils.isEmpty(obj.getJTQKRKS()))
            jtrks.setText(obj.getJTQKRKS());
        if (obj != null && !StringUtils.isEmpty(obj.getJTQKJTJG()))
            jtjg.setText(obj.getJTQKJTJG());
        jzqk = (Spinner) findViewById(R.id.jzqk);

        //生活环境
        cfpfss = (Spinner) findViewById(R.id.cfpfss);
        rllx = (Spinner) findViewById(R.id.rllx);
        yinshui = (Spinner) findViewById(R.id.ys);
        ceshuo = (Spinner) findViewById(R.id.cs);
        qcl = (Spinner) findViewById(R.id.qcl);
        Resources res = getResources();
        String[] cfpf = res.getStringArray(R.array.cfpfss);
        List<Xx> cfpflist = new ArrayList<Xx>();
        for (int i = 0; i < cfpf.length; i++) {
            Xx x = new Xx();
            x.setName(cfpf[i]);
            cfpflist.add(x);
        }
        cfpfss.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, cfpflist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getCFPFSS())) {
            cfpfss.setSelection(Integer.parseInt(obj.getCFPFSS()) - 1);
        }else{
            cfpfss.setSelection(0);
        }
        cfpfss.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                obj.setCFPFSS((position + 1) + "");
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        String[] rl = res.getStringArray(R.array.rllx);
        List<Xx> rllist = new ArrayList<Xx>();
        for (int i = 0; i < rl.length; i++) {
            Xx x = new Xx();
            x.setName(rl[i]);
            rllist.add(x);
        }
        rllx.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, rllist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getRLLX())) {
            rllx.setSelection(Integer.parseInt(obj.getRLLX()) - 1);
        }
        rllx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
//                rllxs = (position + 1) + "";
                obj.setRLLX((position + 1) + "");
            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        //饮水
        String[] ys = res.getStringArray(R.array.yinshui);
        List<Xx> yslist = new ArrayList<Xx>();
        for (int i = 0; i < ys.length; i++) {
            Xx x = new Xx();
            x.setName(ys[i]);
            yslist.add(x);
        }
        yinshui.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, yslist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getYINSHUI())) {
            yinshui.setSelection(Integer.parseInt(obj.getYINSHUI()) - 1);
        }
        yinshui.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                //yinshuis = (position + 1) + "";
                obj.setYINSHUI((position + 1) + "");
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        //厕所
        String[] cs = res.getStringArray(R.array.cesuo);
        List<Xx> cslist = new ArrayList<Xx>();
        for (int i = 0; i < cs.length; i++) {
            Xx x = new Xx();
            x.setName(cs[i]);
            cslist.add(x);
        }
        ceshuo.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, cslist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getCESUO())) {
            ceshuo.setSelection(Integer.parseInt(obj.getCESUO()) - 1);
        }
        ceshuo.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                //ceshuos = (position + 1) + "";
                obj.setCESUO((position + 1) + "");
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        //禽畜栏
        String[] qc = res.getStringArray(R.array.qcl);
        List<Xx> qclist = new ArrayList<Xx>();
        for (int i = 0; i < qc.length; i++) {
            Xx x = new Xx();
            x.setName(qc[i]);
            qclist.add(x);
        }
        qcl.setAdapter(new CommonAdapter<Xx>(jm_info_add.this, qclist, R.layout.sp_item) {
            @Override
            public void convert(ViewHolder helper, Xx item) {
                helper.setText(R.id.name, item.getName());
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getQCL())) {
            qcl.setSelection(Integer.parseInt(obj.getQCL()) - 1);
        }
        qcl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                //qcls = (position + 1) + "";
                obj.setQCL((position + 1) + "");
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        ycbs = (RadioGroup) findViewById(R.id.ycbs);
        ycbs.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.ycb_wu) {
                    ycbmc.setEnabled(false);
                    obj.setYCBS("1");
                } else {
                    obj.setYCBS("2");
                    ycbmc.setEnabled(true);
                }
            }
        });

        //药物过敏
        ywgms = (MultiLineChooseLayout) findViewById(R.id.gms);
        ywgmsdata.add("无");
        ywgmsdata.add("青霉素");
        ywgmsdata.add("磺胺");
        ywgmsdata.add("链霉素");
        ywgmsdata.add("其他");
        ywgms.setList(ywgmsdata);
        if (obj != null && !StringUtils.isEmpty(obj.getYWGMS())) {
            if (obj.getYWGMS().contains(",")) {
                String[] ss = obj.getYWGMS().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        if(Integer.parseInt(ss[i])==0){
                            ywgms.setIndexItemSelected(Integer.parseInt(ss[i]));
                        }else{
                            ywgms.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                        }
                    }
                }
            } else {
                if(Integer.parseInt(obj.getYWGMS())==0){
                    ywgms.setIndexItemSelected(Integer.parseInt(obj.getYWGMS()));
                }else{
                    ywgms.setIndexItemSelected(Integer.parseInt(obj.getYWGMS())-1);
                }
            }
        }
        ywgms.setOnItemClickListener(new MultiLineChooseLayout.onItemClickListener() {
            @Override
            public void onItemClick(int position, String text) {

            }
        });
        //暴露史
        bls = (MultiLineChooseLayout) findViewById(R.id.bls);
        blsdata.add("无");
        blsdata.add("化学品");
        blsdata.add("毒品");
        blsdata.add("射线");
        bls.setList(blsdata);
        if (obj != null && !StringUtils.isEmpty(obj.getBLS())) {
            if (obj.getBLS().contains(",")) {
                String[] ss = obj.getBLS().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if (!StringUtils.isEmpty(ss[i])) {
                        bls.setIndexItemSelected(Integer.parseInt(ss[i]));
                    }
                }
            } else {
                bls.setIndexItemSelected(Integer.parseInt(obj.getBLS()));
            }
        }
        bls.setOnItemClickListener(new MultiLineChooseLayout.onItemClickListener() {
            @Override
            public void onItemClick(int position, String text) {

            }
        });
        //既往史
        jws = (MultiLineChooseLayout) findViewById(R.id.jws);
        jwsdata.add("无");
        jwsdata.add("高血压");
        jwsdata.add("糖尿病");
        jwsdata.add("冠心病");
        jwsdata.add("慢性阻塞性肺疾病");
        jwsdata.add("恶性肿瘤");
        jwsdata.add("脑卒中");
        jwsdata.add("严重精神障碍");
        jwsdata.add("结核病");
        jwsdata.add("肝炎");
        jwsdata.add("其他法定传染病");
        jwsdata.add("职业病");
        jwsdata.add("其他");
        jws.setList(jwsdata);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSJB())) {
            if (obj.getJWSJB().contains(",")) {
                String[] ss = obj.getJWSJB().split(",");
                for (int i = 0; i < ss.length; i++) {
                    if(null != ss[i] && "0".equals(ss[i])){
                        jws.setIndexItemSelected(Integer.parseInt(ss[i]));
                    }else if(null != ss[i] && "A".equals(ss[i])){
                        jws.setIndexItemSelected(9);
                    }else if(null != ss[i] && "B".equals(ss[i])){
                        jws.setIndexItemSelected(10);
                    }else if(null != ss[i] && "C".equals(ss[i])){
                        jws.setIndexItemSelected(11);
                    }else if(null != ss[i] && "D".equals(ss[i])){
                        jws.setIndexItemSelected(12);
                    }else{
                        jws.setIndexItemSelected(Integer.parseInt(ss[i])-1);
                    }
                }
            } else {
                if(null != obj.getJWSJB() && "0".equals(obj.getJWSJB())){
                    jws.setIndexItemSelected(Integer.parseInt(obj.getJWSJB()));
                }else if(null != obj.getJWSJB() && "A".equals(obj.getJWSJB())){
                    jws.setIndexItemSelected(9);
                }else if(null != obj.getJWSJB() && "B".equals(obj.getJWSJB())){
                    jws.setIndexItemSelected(10);
                }else if(null != obj.getJWSJB() && "C".equals(obj.getJWSJB())){
                    jws.setIndexItemSelected(11);
                }else if(null != obj.getJWSJB() && "D".equals(obj.getJWSJB())){
                    jws.setIndexItemSelected(12);
                }else{
                    jws.setIndexItemSelected(Integer.parseInt(obj.getJWSJB())-1);
                }
            }
        }
        jws.setOnItemClickListener(new MultiLineChooseLayout.onItemClickListener() {
            @Override
            public void onItemClick(int position, String text) {
//                if (text.equals("无")) {
//                    jws.cancelAllSelectedItems();
//                    jws.setIndexItemSelected(0);
//                }
//                if (text.equals("其他")) {
//                    jws.cancelAllSelectedItems();
//                    jws.setIndexItemSelected(12);
//                }
            }
        });
        //基本信息
        gxqqzrq = (TextView) findViewById(R.id.r1);
        if (obj != null && !StringUtils.isEmptyRq(obj.getGXYQZRQ()))
            gxqqzrq.setText(obj.getGXYQZRQ());
        gxqqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        gxqqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        tnbqzrq = (TextView) findViewById(R.id.r2);
        if (obj != null && !StringUtils.isEmptyRq(obj.getTNBQZRQ()))
            tnbqzrq.setText(obj.getTNBQZRQ());
        tnbqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        tnbqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        gxbqzrq = (TextView) findViewById(R.id.r3);
        if (obj != null && !StringUtils.isEmptyRq(obj.getGXBQZRQ()))
            gxbqzrq.setText(obj.getGXBQZRQ());
//        JWSJBQT = (EditText) findViewById(R.id.jws_qt);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSJBQT()))
            JWSJBQT.setText(obj.getJWSJBQT());
        gxbqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        gxbqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        mxzsxfjbqzrq = (TextView) findViewById(R.id.r4);
        if (obj != null && !StringUtils.isEmptyRq(obj.getMXZSXFJBQZRQ()))
            mxzsxfjbqzrq.setText(obj.getMXZSXFJBQZRQ());
        mxzsxfjbqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        mxzsxfjbqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        exzlqzrq = (TextView) findViewById(R.id.r5);
        if (obj != null && !StringUtils.isEmptyRq(obj.getEXZLQZRQ()))
            exzlqzrq.setText(obj.getEXZLQZRQ());
        exzlqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        exzlqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        nczqzrq = (TextView) findViewById(R.id.r6);
        if (obj != null && !StringUtils.isEmptyRq(obj.getNCZQZRQ()))
            nczqzrq.setText(obj.getNCZQZRQ());
        nczqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        nczqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        jsbqzrq = (TextView) findViewById(R.id.r7);
        if (obj != null && !StringUtils.isEmptyRq(obj.getJSBQZRQ()))
            jsbqzrq.setText(obj.getJSBQZRQ());
        jsbqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        jsbqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        jhbqzrq = (TextView) findViewById(R.id.r8);
        if (obj != null && !StringUtils.isEmptyRq(obj.getJHBQZRQ()))
            jhbqzrq.setText(obj.getJHBQZRQ());
        jhbqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        jhbqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        gyqzrq = (TextView) findViewById(R.id.r9);
        if (obj != null && !StringUtils.isEmptyRq(obj.getGYQZRQ()))
            gyqzrq.setText(obj.getGYQZRQ());
        gyqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        gyqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        crbqzrq = (TextView) findViewById(R.id.r10);
        if (obj != null && !StringUtils.isEmptyRq(obj.getCRBQZRQ()))
            crbqzrq.setText(obj.getCRBQZRQ());
        crbqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        crbqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        zybqzrq = (TextView) findViewById(R.id.r11);
        if (obj != null && !StringUtils.isEmptyRq(obj.getZYBQZRQ()))
            zybqzrq.setText(obj.getZYBQZRQ());
        zybqzrq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        zybqzrq.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });


        //手术、外伤、输血
        ss = (RadioGroup) findViewById(R.id.ss);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSSS())) {
            switch (Integer.parseInt(obj.getJWSSS())) {
                case 1:
                    ss.check(R.id.ss_wu);
                    break;
                case 2:
                    ss.check(R.id.ss_you);
                    break;
            }
        }
        ss.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.ss_wu) {
                    ssmc1.setEnabled(false);
                    ssmc2.setEnabled(false);
                    sssj1.setEnabled(false);
                    sssj2.setEnabled(false);
                    obj.setJWSSS("1");
                } else {
                    ssmc1.setEnabled(true);
                    ssmc2.setEnabled(true);
                    sssj1.setEnabled(true);
                    sssj2.setEnabled(true);
                    obj.setJWSSS("2");
                }
            }
        });
        sssj1 = (TextView) findViewById(R.id.sssj1);
        sssj2 = (TextView) findViewById(R.id.sssj2);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSSSMC1())) {
            ssmc1.setText(obj.getJWSSSMC1());
        }
        if (obj != null && !StringUtils.isEmptyRq(obj.getJWSSSRQ1())) {
            sssj1.setText(obj.getJWSSSRQ1());
        }
        if (obj != null && !StringUtils.isEmpty(obj.getJWSSSMC2())) {
            ssmc2.setText(obj.getJWSSSMC2());
        }
        if (obj != null && !StringUtils.isEmptyRq(obj.getJWSSSRQ2())) {
            sssj2.setText(obj.getJWSSSRQ2());
        }
        sssj1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        sssj1.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        sssj2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        sssj2.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        ws = (RadioGroup) findViewById(R.id.ws);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSWS())) {
            switch (Integer.parseInt(obj.getJWSWS())) {
                case 1:
                    ws.check(R.id.ws_wu);
                    break;
                case 2:
                    ws.check(R.id.ws_you);
                    break;
            }
        }
        ws.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.ws_wu) {
                    wsmc1.setEnabled(false);
                    wsmc2.setEnabled(false);
                    wssj1.setEnabled(false);
                    wssj2.setEnabled(false);
                } else {
                    wsmc1.setEnabled(true);
                    wsmc2.setEnabled(true);
                    wssj1.setEnabled(true);
                    wssj2.setEnabled(true);
                }
            }
        });
        wssj1 = (TextView) findViewById(R.id.wssj1);
        wssj2 = (TextView) findViewById(R.id.wssj2);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSWSMC1())) {
            wsmc1.setText(obj.getJWSWSMC1());
        }
        if (obj != null && !StringUtils.isEmptyRq(obj.getJWSWSRQ1())) {
            wssj1.setText(obj.getJWSWSRQ1());
        }
        if (obj != null && !StringUtils.isEmpty(obj.getJWSWSMC2())) {
            wsmc2.setText(obj.getJWSWSMC2());
        }
        if (obj != null && !StringUtils.isEmptyRq(obj.getJWSWSRQ2())) {
            wssj2.setText(obj.getJWSWSRQ2());
        }
        wssj1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        wssj1.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        wssj2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        wssj2.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        sx = (RadioGroup) findViewById(R.id.sx);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSSX())) {
            switch (Integer.parseInt(obj.getJWSSX())) {
                case 1:
                    sx.check(R.id.sx_wu);
                    break;
                case 2:
                    sx.check(R.id.sx_you);
                    break;
            }
        }
        sx.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.sx_wu) {
                    sxyy1.setEnabled(false);
                    sxyy2.setEnabled(false);
                    sxsj1.setEnabled(false);
                    sxsj2.setEnabled(false);
                } else {
                    sxyy1.setEnabled(true);
                    sxyy2.setEnabled(true);
                    sxsj1.setEnabled(true);
                    sxsj2.setEnabled(true);
                }
            }
        });
        sxsj1 = (TextView) findViewById(R.id.sxsj1);
        sxsj2 = (TextView) findViewById(R.id.sxsj2);
        if (obj != null && !StringUtils.isEmpty(obj.getJWSSXYY1())) {
            sxyy1.setText(obj.getJWSSXYY1());
        }
        if (obj != null && !StringUtils.isEmptyRq(obj.getJWSSXRQ1())) {
            sxsj1.setText(obj.getJWSSXRQ1());
        }
        if (obj != null && !StringUtils.isEmpty(obj.getJWSSXYY2())) {
            sxyy2.setText(obj.getJWSSXYY2());
        }
        if (obj != null && !StringUtils.isEmptyRq(obj.getJWSWSRQ2())) {
            sxsj2.setText(obj.getJWSSXRQ2());
        }
        sxsj1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        sxsj1.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        sxsj2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        sxsj2.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });


        //支付方式

        type1 = (CheckBox) findViewById(R.id.type1);
        type2 = (CheckBox) findViewById(R.id.type2);
        type3 = (CheckBox) findViewById(R.id.type3);
        type4 = (CheckBox) findViewById(R.id.type4);
        type5 = (CheckBox) findViewById(R.id.type5);
        type6 = (CheckBox) findViewById(R.id.type6);
        type7 = (CheckBox) findViewById(R.id.type7);
        if (obj != null && !StringUtils.isEmpty(obj.getYLFYZFFS())) {
            if (obj.getYLFYZFFS().contains("1"))
                type1.setChecked(true);
            if (obj.getYLFYZFFS().contains("2"))
                type2.setChecked(true);
            if (obj.getYLFYZFFS().contains("3"))
                type3.setChecked(true);
            if (obj.getYLFYZFFS().contains("4"))
                type4.setChecked(true);
            if (obj.getYLFYZFFS().contains("5"))
                type5.setChecked(true);
            if (obj.getYLFYZFFS().contains("6"))
                type6.setChecked(true);
            if (obj.getYLFYZFFS().contains("7"))
                type7.setChecked(true);

        }
//        ybkh1 = (EditText) findViewById(R.id.ybkh1);
//        ybkh2 = (EditText) findViewById(R.id.ybkh2);
//        ybkh3 = (EditText) findViewById(R.id.ybkh3);
//        zffsqt = (EditText) findViewById(R.id.qt);
        if (obj != null && !StringUtils.isEmpty(obj.getZGKH()))
            ybkh1.setText(obj.getZGKH());
        if (obj != null && !StringUtils.isEmpty(obj.getJMKH()))
            ybkh2.setText(obj.getJMKH());
        if (obj != null && !StringUtils.isEmpty(obj.getPKJZKH()))
            ybkh3.setText(obj.getPKJZKH());
        if (obj != null && !StringUtils.isEmpty(obj.getYLFYZFFSQT()))
            zffsqt.setText(obj.getYLFYZFFSQT());
        type1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type2.setChecked(false);
                    type3.setChecked(false);
                    type4.setChecked(false);
                    type5.setChecked(false);
                    type6.setChecked(false);
                    type7.setChecked(false);
                    ybkh1.setEnabled(true);
                    YLZFSF = "1";
                    obj.setYLFYZFFS("1");
                } else {
                    YLZFSF = "";
                    ybkh1.setEnabled(false);
                    obj.setYLFYZFFS("");
                }
            }
        });
        type2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type1.setChecked(false);
                    type3.setChecked(false);
                    type4.setChecked(false);
                    type5.setChecked(false);
                    type6.setChecked(false);
                    type7.setChecked(false);
                    ybkh2.setEnabled(true);
                    YLZFSF = "2";
                    obj.setYLFYZFFS("2");
                } else {
                    YLZFSF = "";
                    obj.setYLFYZFFS("");
                    ybkh2.setEnabled(false);
                }

            }
        });
        type3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type1.setChecked(false);
                    type2.setChecked(false);
                    type4.setChecked(false);
                    type5.setChecked(false);
                    type6.setChecked(false);
                    type7.setChecked(false);
                    ybkh3.setEnabled(true);
                    YLZFSF = "3";
                    obj.setYLFYZFFS("3");
                } else {
                    YLZFSF = "";
                    obj.setYLFYZFFS("");
                    ybkh3.setEnabled(false);
                }

            }
        });
        type4.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type1.setChecked(false);
                    type3.setChecked(false);
                    type2.setChecked(false);
                    type5.setChecked(false);
                    type6.setChecked(false);
                    type7.setChecked(false);
                    YLZFSF = "4";
                    obj.setYLFYZFFS("4");
                } else {
                    YLZFSF = "";
                    obj.setYLFYZFFS("");
                }

            }
        });
        type5.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type1.setChecked(false);
                    type3.setChecked(false);
                    type4.setChecked(false);
                    type2.setChecked(false);
                    type6.setChecked(false);
                    type7.setChecked(false);
                    YLZFSF = "5";
                    obj.setYLFYZFFS("5");
                } else {
                    YLZFSF = "";
                    obj.setYLFYZFFS("");
                }

            }
        });
        type6.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type1.setChecked(false);
                    type3.setChecked(false);
                    type4.setChecked(false);
                    type5.setChecked(false);
                    type2.setChecked(false);
                    type7.setChecked(false);
                    YLZFSF = "6";
                    obj.setYLFYZFFS("6");
                } else {
                    YLZFSF = "";
                    obj.setYLFYZFFS("");
                }

            }
        });
        type7.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    type1.setChecked(false);
                    type3.setChecked(false);
                    type4.setChecked(false);
                    type5.setChecked(false);
                    type6.setChecked(false);
                    type2.setChecked(false);
                    zffsqt.setEnabled(true);
                    YLZFSF = "7";
                    obj.setYLFYZFFS("7");
                } else {
                    YLZFSF = "";
                    obj.setYLFYZFFS("");
                    zffsqt.setEnabled(false);
                }

            }
        });
        //基本信息
       /* SCJDRQ = (TextView) findViewById(R.id.scjdrq);
        if (obj!=null&&!StringUtils.isEmpty(obj.getSCJDRQ()))
            SCJDRQ.setText(obj.getSCJDRQ());
        SCJDRQ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        SCJDRQ.setText(time.split(" ")[0]);
                    }
                }, startDate, now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });*/
        if (getIntent().getStringExtra("type").equals("edit")) {
            dahll = (LinearLayout) findViewById(R.id.dahll);
            dahll.setVisibility(View.VISIBLE);
//            jkdah = (TextView) findViewById(R.id.dah);
            if (obj != null && !StringUtils.isEmpty(obj.getJKDAH()))
                jkdah.setText(obj.getJKDAH());

            ll_xzqh = (LinearLayout) findViewById(R.id.ll_xzqh);
            ll_xzqh.setVisibility(View.GONE);
        }
        if (getIntent().getStringExtra("type").equals("add")) {
            xzqhname.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivityForResult(new Intent(con, TreeXzqhActivity.class).putExtra("cname", "tnb.class"), 1);
                }
            });
        }
//        XINGMING = (EditText) findViewById(R.id.xm);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGMING()))
            XINGMING.setText(obj.getXINGMING());
//        SFZH = (EditText) findViewById(R.id.sfzh);
        if (obj != null && !StringUtils.isEmpty(obj.getSFZH()))
            SFZH.setText(obj.getSFZH());
        SFZH.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean hasFocus) {
                if (hasFocus) {
                    // 此处为得到焦点时的处理内容
                } else {
                    String idcard = SFZH.getText().toString();
                    if (null != idcard && !"".equals(idcard) && idcard.length() > 15) {
                        // 此处为失去焦点时的处理内容
                        SimpleDateFormat formatter1 = new SimpleDateFormat("yyyyMMdd");
                        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
                        //CSRQ.setText(idcard.substring(6, 14));
                        try {
                            System.out.println("ss2============" + idcard.substring(6, 14));
                            System.out.println("ss1============" + formatter1.parse(idcard.substring(6, 14)));
                            System.out.println("ss1============" + formatter.format(formatter1.parse(idcard.substring(6, 14))));
                            CSRQ.setText(formatter.format(formatter1.parse(idcard.substring(6, 14))));
                        } catch (ParseException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        });
        //出生日期
        //CSRQ = (TextView) findViewById(R.id.csrq);
        CSRQ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        CSRQ.setText(time.split(" ")[0]);
                    }
                }, "1900-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getCSRQ()))
            CSRQ.setText(obj.getCSRQ());
        //死亡日期
//        SWRQ = (TextView) findViewById(R.id.swrq);
        SWRQ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        SWRQ.setText(time.split(" ")[0]);
                    }
                }, "1900-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        if (obj != null && !StringUtils.isEmptyRq(obj.getSWRQ()))
            SWRQ.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSWRQ(), DateConvert.YMD), DateConvert.YMD)+"    ");

        //NIANLING = (EditText) findViewById(R.id.nl);
        if (obj != null && !StringUtils.isEmpty(obj.getNIANLING()))
            NIANLING.setText(obj.getNIANLING());
        //性别选择
//        XINGBIE = (RadioGroup) findViewById(R.id.xb);
        if (obj != null && !StringUtils.isEmpty(obj.getXINGBIE())) {
            switch (Integer.parseInt(obj.getXINGBIE())) {
                case 1:
                    XINGBIE.check(R.id.nan);
                    break;
                case 2:
                    XINGBIE.check(R.id.nv);
                    break;
                case 9:
                    XINGBIE.check(R.id.wsm);
                    break;
                case 0:
                    XINGBIE.check(R.id.wz);
                    break;
            }
        } else {
            //XINGBIE.check(R.id.nan);
        }
        XINGBIE.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (R.id.nan == checkedId) {
                    obj.setXINGBIE("1");
                }
                if (R.id.nv == checkedId)
                    obj.setXINGBIE("2");
                if (R.id.wsm == checkedId)
                    obj.setXINGBIE("9");
                if (R.id.wz == checkedId)
                    obj.setXINGBIE("0");
            }
        });

        //人员状态选择
//        RYSTATUS = (RadioGroup) findViewById(R.id.rystatus);
        ll_swrq = (LinearLayout)findViewById(R.id.ll_swrq);
        if (obj != null && !StringUtils.isEmpty(obj.getSTATUS())) {
            switch (Integer.parseInt(obj.getSTATUS())) {
                case 1:
                    RYSTATUS.check(R.id.rystatus_zc);
                    ll_swrq.setVisibility(View.GONE);
                    break;
                case 2:
                    RYSTATUS.check(R.id.rystatus_qc);
                    ll_swrq.setVisibility(View.GONE);
                    break;
                case 3:
                    RYSTATUS.check(R.id.rystatus_hj);
                    ll_swrq.setVisibility(View.GONE);
                    break;
                case 4:
                    RYSTATUS.check(R.id.rystatus_sw);
                    ll_swrq.setVisibility(View.VISIBLE);
                    break;
                default :
                    RYSTATUS.check(R.id.rystatus_zc);
                    ll_swrq.setVisibility(View.GONE);
                    break;
            }
        } else {
            RYSTATUS.check(R.id.rystatus_zc);
            ll_swrq.setVisibility(View.GONE);
        }
        RYSTATUS.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (R.id.rystatus_zc == checkedId) {
                    obj.setSTATUS("1");
                    ll_swrq.setVisibility(View.GONE);
                    SWRQ.setText("");
                }
                if (R.id.rystatus_qc == checkedId) {
                    obj.setSTATUS("2");
                    ll_swrq.setVisibility(View.GONE);
                    SWRQ.setText("");
                }
                if (R.id.rystatus_hj == checkedId) {
                    obj.setSTATUS("3");
                    ll_swrq.setVisibility(View.GONE);
                    SWRQ.setText("");
                }
                if (R.id.rystatus_sw == checkedId) {
                    obj.setSTATUS("4");
                    ll_swrq.setVisibility(View.VISIBLE);
                }
            }
        });
//        GZDW = (EditText) findViewById(R.id.gzdw);
        if (obj != null && !StringUtils.isEmpty(obj.getGZDW()))
            GZDW.setText(obj.getGZDW());
//        LXDH = (EditText) findViewById(R.id.LXDH);
        if (obj != null && !StringUtils.isEmpty(obj.getLXDH()))
            LXDH.setText(obj.getLXDH());
        bddh1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!StringUtils.isEmpty(LXDH.getText().toString())){
                    SweetAlertDialogUtil.callDialog(con,"确认提示", "您确认拨打居民本人电话吗？", "确定", LXDH.getText().toString());
                }
            }
        });

//        LXRXM = (EditText) findViewById(R.id.lxrxm);
        if (obj != null && !StringUtils.isEmpty(obj.getLXRXM()))
            LXRXM.setText(obj.getLXRXM());
//        LXRDH = (EditText) findViewById(R.id.lxrdh);
        if (obj != null && !StringUtils.isEmpty(obj.getLXRDH()))
            LXRDH.setText(obj.getLXRDH());
        bddh2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!StringUtils.isEmpty(LXRDH.getText().toString())){
                    SweetAlertDialogUtil.callDialog(con,"确认提示", "您确认拨打居民联系人电话吗？", "确定", LXRDH.getText().toString());
                }
            }
        });
        //常住类型
//        CZLX = (RadioGroup) findViewById(R.id.czlx);
        if (obj != null && !StringUtils.isEmpty(obj.getCZLX())) {
            switch (Integer.parseInt(obj.getCZLX())) {
                case 1:
                    CZLX.check(R.id.hj);
                    break;
                case 2:
                    CZLX.check(R.id.fhj);
                    break;

            }
        } else {
            CZLX.check(R.id.hj);
        }
        CZLX.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (R.id.hj == checkedId) {
                    obj.setCZLX("1");
                }
                if (R.id.fhj == checkedId)
                    obj.setCZLX("2");

            }
        });
//        HJDZ = (EditText) findViewById(R.id.hjdz);
        if (obj != null && !StringUtils.isEmpty(obj.getHJDZ()))
            HJDZ.setText(obj.getHJDZ());
        if (obj != null && !StringUtils.isEmpty(obj.getCZDZ()))
            czdz.setText(obj.getCZDZ());
//        MINZU = (EditText) findViewById(R.id.mz);
        if (obj != null && !StringUtils.isEmpty(obj.getMINZU()))
            MINZU.setText(obj.getMINZU());
        //血型
//        XUEXING = (RadioGroup) findViewById(R.id.xx);
        if (obj != null && !StringUtils.isEmpty(obj.getXUEXING())) {
            switch (Integer.parseInt(obj.getXUEXING())) {
                case 1:
                    XUEXING.check(R.id.xxa);
                    break;
                case 2:
                    XUEXING.check(R.id.xxb);
                    break;
                case 3:
                    XUEXING.check(R.id.xxo);
                    break;
                case 4:
                    XUEXING.check(R.id.xxab);
                    break;
            }
        } else {
            XUEXING.check(R.id.xxa);
        }
        XUEXING.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (R.id.xxa == checkedId)
                    obj.setXUEXING("1");
                if (R.id.xxb == checkedId)
                    obj.setXUEXING("2");
                if (R.id.xxo == checkedId)
                    obj.setXUEXING("3");
                if (R.id.xxab == checkedId)
                    obj.setXUEXING("4");
            }
        });
        //是否RH阴性
//        XUEXINGRH = (RadioGroup) findViewById(R.id.rh);
        if (obj != null && !StringUtils.isEmpty(obj.getXUEXINGRH())) {
            switch (Integer.parseInt(obj.getXUEXINGRH())) {
                case 1:
                    XUEXINGRH.check(R.id.rh1);
                    break;
                case 2:
                    XUEXINGRH.check(R.id.rh2);
                    break;
                case 3:
                    XUEXINGRH.check(R.id.rh3);
                    break;

            }
        } else {
            XUEXINGRH.check(R.id.rh1);
        }
        XUEXINGRH.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.rh1)
                    obj.setXUEXINGRH("1");
                if (checkedId == R.id.rh2)
                    obj.setXUEXINGRH("2");
                if (checkedId == R.id.rh3)
                    obj.setXUEXINGRH("3");
            }
        });
    }

    //导航的点击事件
    public void showMenu() {
        t1 = (LinearLayout) findViewById(R.id.tv_wqy);
        t6 = (LinearLayout) findViewById(R.id.t6);
        t5 = (LinearLayout) findViewById(R.id.t5);
        t4 = (LinearLayout) findViewById(R.id.t4);
        t3 = (LinearLayout) findViewById(R.id.tv_tj);
        t2 = (LinearLayout) findViewById(R.id.tv_yqy);
        i1 = (ImageView) findViewById(R.id.i1);
        i2 = (ImageView) findViewById(R.id.i2);
        i3 = (ImageView) findViewById(R.id.i3);
        i4 = (ImageView) findViewById(R.id.i4);
        i5 = (ImageView) findViewById(R.id.i5);
        i6 = (ImageView) findViewById(R.id.i6);
        s1 = (LinearLayout) findViewById(R.id.l1);
        s2 = (LinearLayout) findViewById(R.id.l2);
        s3 = (LinearLayout) findViewById(R.id.l3);
        s4 = (LinearLayout) findViewById(R.id.l4);
        s5 = (LinearLayout) findViewById(R.id.l5);
        s6 = (LinearLayout) findViewById(R.id.l6);
        i1.setImageResource(R.mipmap.xsj);
        s1.setVisibility(View.VISIBLE);

        LinearLayout.LayoutParams linearParams =(LinearLayout.LayoutParams) s1.getLayoutParams(); //取控件textView当前的布局参数 linearParams.height = 20;// 控件的高强制设成20
        //linearParams.width = 30;// 控件的宽强制设成30
        Display display = getWindowManager().getDefaultDisplay();
        int width = display.getWidth();
        int height = display.getHeight();
        linearParams.height =  height-600;// 控件的宽强制设成30
        s1.setLayoutParams(linearParams); //使设置好的布局参数应用到控件

        t1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i6.setImageResource(R.mipmap.zsj);
                i5.setImageResource(R.mipmap.zsj);
                i4.setImageResource(R.mipmap.zsj);
                i3.setImageResource(R.mipmap.zsj);
                i2.setImageResource(R.mipmap.zsj);
                if (s1.getVisibility() == View.VISIBLE) {
                    i1.setImageResource(R.mipmap.zsj);
                    s1.setVisibility(View.GONE);
                } else {
                    i1.setImageResource(R.mipmap.xsj);
                    s1.setVisibility(View.VISIBLE);
                }
                s2.setVisibility(View.GONE);
                s3.setVisibility(View.GONE);
                s4.setVisibility(View.GONE);
                s5.setVisibility(View.GONE);
                s6.setVisibility(View.GONE);

            }
        });
        t2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i6.setImageResource(R.mipmap.zsj);
                i5.setImageResource(R.mipmap.zsj);
                i4.setImageResource(R.mipmap.zsj);
                i3.setImageResource(R.mipmap.zsj);
                i1.setImageResource(R.mipmap.zsj);
                if (s2.getVisibility() == View.VISIBLE) {
                    i2.setImageResource(R.mipmap.zsj);
                    s2.setVisibility(View.GONE);
                } else {
                    i2.setImageResource(R.mipmap.xsj);
                    s2.setVisibility(View.VISIBLE);
                }
                s1.setVisibility(View.GONE);
                s3.setVisibility(View.GONE);
                s4.setVisibility(View.GONE);
                s5.setVisibility(View.GONE);
                s6.setVisibility(View.GONE);

            }
        });
        t3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i6.setImageResource(R.mipmap.zsj);
                i5.setImageResource(R.mipmap.zsj);
                i4.setImageResource(R.mipmap.zsj);
                i1.setImageResource(R.mipmap.zsj);
                i2.setImageResource(R.mipmap.zsj);
                if (s3.getVisibility() == View.VISIBLE) {
                    i3.setImageResource(R.mipmap.zsj);
                    s3.setVisibility(View.GONE);
                } else {
                    i3.setImageResource(R.mipmap.xsj);
                    s3.setVisibility(View.VISIBLE);
                }
                s2.setVisibility(View.GONE);
                s1.setVisibility(View.GONE);
                s4.setVisibility(View.GONE);
                s5.setVisibility(View.GONE);
                s6.setVisibility(View.GONE);

            }
        });
        t4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i6.setImageResource(R.mipmap.zsj);
                i5.setImageResource(R.mipmap.zsj);
                i1.setImageResource(R.mipmap.zsj);
                i3.setImageResource(R.mipmap.zsj);
                i2.setImageResource(R.mipmap.zsj);
                if (s4.getVisibility() == View.VISIBLE) {
                    i4.setImageResource(R.mipmap.zsj);
                    s4.setVisibility(View.GONE);
                } else {
                    i4.setImageResource(R.mipmap.xsj);
                    s4.setVisibility(View.VISIBLE);
                }
                s2.setVisibility(View.GONE);
                s3.setVisibility(View.GONE);
                s1.setVisibility(View.GONE);
                s5.setVisibility(View.GONE);
                s6.setVisibility(View.GONE);

            }
        });
        t5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i6.setImageResource(R.mipmap.zsj);
                i1.setImageResource(R.mipmap.zsj);
                i4.setImageResource(R.mipmap.zsj);
                i3.setImageResource(R.mipmap.zsj);
                i2.setImageResource(R.mipmap.zsj);
                if (s5.getVisibility() == View.VISIBLE) {
                    i5.setImageResource(R.mipmap.zsj);
                    s5.setVisibility(View.GONE);
                } else {
                    i5.setImageResource(R.mipmap.xsj);
                    s5.setVisibility(View.VISIBLE);
                }
                s2.setVisibility(View.GONE);
                s3.setVisibility(View.GONE);
                s4.setVisibility(View.GONE);
                s1.setVisibility(View.GONE);
                s6.setVisibility(View.GONE);

            }
        });
        t6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                i1.setImageResource(R.mipmap.zsj);
                i5.setImageResource(R.mipmap.zsj);
                i4.setImageResource(R.mipmap.zsj);
                i3.setImageResource(R.mipmap.zsj);
                i2.setImageResource(R.mipmap.zsj);
                if (s6.getVisibility() == View.VISIBLE) {
                    i6.setImageResource(R.mipmap.zsj);
                    s6.setVisibility(View.GONE);
                } else {
                    i6.setImageResource(R.mipmap.xsj);
                    s6.setVisibility(View.VISIBLE);
                }
                s2.setVisibility(View.GONE);
                s3.setVisibility(View.GONE);
                s4.setVisibility(View.GONE);
                s5.setVisibility(View.GONE);
                s1.setVisibility(View.GONE);

            }
        });
    }

    private void saveData(){
        if (getIntent().getStringExtra("type").equals("add") && StringUtils.isEmpty(xzqh.getText().toString())) {
            SweetAlertDialogUtil.WarningDialog(con, "提示", "请选择行政区划");
        } else {
            /*                  obj.setSCJDRQ(SCJDRQ.getText().toString());*/
            obj.setXINGMING(XINGMING.getText().toString());
            Log.i("SFZHStr", SFZH.getText().toString());
            obj.setSFZH(SFZH.getText().toString());
            obj.setCSRQ(CSRQ.getText().toString());
            obj.setSWRQ(SWRQ.getText().toString());
            obj.setNIANLING(NIANLING.getText().toString());
            obj.setGZDW(GZDW.getText().toString());
            obj.setLXDH(LXDH.getText().toString());
            obj.setLXRXM(LXRXM.getText().toString());
            obj.setLXRDH(LXRDH.getText().toString());
            obj.setHJDZ(HJDZ.getText().toString());
            obj.setCZDZ(czdz.getText().toString());
            obj.setMINZU(MINZU.getText().toString());

            obj.setZGKH(ybkh1.getText().toString());
            obj.setJMKH(ybkh2.getText().toString());
            obj.setPKJZKH(ybkh3.getText().toString());
            obj.setYLFYZFFSQT(zffsqt.getText().toString());

            ArrayList<Integer> ywgm = ywgms.getAllItemSelectedIndex();
            String ywgms = "";
            for (int i = 0; i < ywgm.size(); i++) {
                if (i == 0) {
                    ywgms = (ywgm.get(i) + 1) + "";
                }else {
                    ywgms = ywgms + "," + (ywgm.get(i) + 1);
                }
            }
            obj.setYWGMS(ywgms);
            ArrayList<Integer> blslist = bls.getAllItemSelectedIndex();
            String blss = "";
            for (int i = 0; i < blslist.size(); i++) {
                if (i == 0)
                    blss = blslist.get(i) + "";
                else
                    blss = blss + "," + blslist.get(i);
            }
            obj.setBLS(blss);
            ArrayList<Integer> jwslist = jws.getAllItemSelectedIndex();
            String jwss = "";
            for (int i = 0; i < jwslist.size(); i++) {
                if (i == 0) {
                    jwss = (jwslist.get(i) + 1) + "";
                }else {
                    if(jwslist.get(i) == 9){
                        jwss = jwss + ",A" ;
                    }else if(jwslist.get(i) == 10){
                        jwss = jwss + ",B";
                    }else if(jwslist.get(i) == 11){
                        jwss = jwss + ",C";
                    }else if(jwslist.get(i) == 12){
                        jwss = jwss + ",D";
                    }else {
                        jwss = jwss + "," + (jwslist.get(i) + 1);
                    }
                }
            }
            obj.setJWSJB(jwss);
            obj.setJWSJBQT(JWSJBQT.getText().toString());
            obj.setGXYQZRQ(gxqqzrq.getText().toString());
            obj.setTNBQZRQ(tnbqzrq.getText().toString());
            obj.setGXBQZRQ(gxbqzrq.getText().toString());
            obj.setMXZSXFJBQZRQ(mxzsxfjbqzrq.getText().toString());
            obj.setEXZLQZRQ(exzlqzrq.getText().toString());
            obj.setNCZQZRQ(nczqzrq.getText().toString());
            obj.setJSBQZRQ(jsbqzrq.getText().toString());
            obj.setJHBQZRQ(jhbqzrq.getText().toString());
            obj.setGYQZRQ(gyqzrq.getText().toString());
            obj.setCRBQZRQ(crbqzrq.getText().toString());
            obj.setZYBQZRQ(zybqzrq.getText().toString());
            obj.setJWSSSMC1(ssmc1.getText().toString());
            obj.setJWSSSRQ1(sssj1.getText().toString());
            obj.setJWSSSMC2(ssmc2.getText().toString());
            obj.setJWSSSRQ2(sssj2.getText().toString());
            obj.setJWSWSMC1(wsmc1.getText().toString());
            obj.setJWSWSRQ1(wssj1.getText().toString());
            obj.setJWSWSMC2(wsmc2.getText().toString());
            obj.setJWSWSRQ2(wssj2.getText().toString());
            obj.setJWSSXYY1(sxyy1.getText().toString());
            obj.setJWSSXRQ1(sxsj1.getText().toString());
            obj.setJWSSXYY2(sxyy2.getText().toString());
            obj.setJWSSXRQ2(sxsj2.getText().toString());
            ArrayList<Integer> fqlist = fq.getAllItemSelectedIndex();
            String fqs = "";
            for (int i = 0; i < fqlist.size(); i++) {
                if (i == 0) {
                    fqs = (fqlist.get(i) + 1) + "";
                }else {
                    if(fqlist.get(i) == 9){
                        fqs = fqs + ",A" ;
                    }else if(fqlist.get(i) == 10){
                        fqs = fqs + ",B";
                    }else if(fqlist.get(i) == 11){
                        fqs = fqs + ",C";
                    }else {
                        fqs = fqs + "," + (fqlist.get(i) + 1);
                    }
                }
            }
            obj.setJZSFQ(fqs);
            ArrayList<Integer> mqlist = mq.getAllItemSelectedIndex();
            String mqs = "";
            for (int i = 0; i < mqlist.size(); i++) {
                if (i == 0) {
                    mqs = (mqlist.get(i) + 1) + "";
                }else {
                    if(mqlist.get(i) == 9){
                        mqs = mqs + ",A" ;
                    }else if(mqlist.get(i) == 10){
                        mqs = mqs + ",B";
                    }else if(mqlist.get(i) == 11){
                        mqs = mqs + ",C";
                    }else {
                        mqs = mqs + "," + (mqlist.get(i) + 1);
                    }
                }
            }
            obj.setJZSMQ(mqs);

            ArrayList<Integer> xdjmlist = xdjm.getAllItemSelectedIndex();
            String xdjms = "";
            for (int i = 0; i < xdjmlist.size(); i++) {
                if (i == 0) {
                    xdjms = (xdjmlist.get(i) + 1) + "";
                }else {
                    if(xdjmlist.get(i) == 9){
                        xdjms = xdjms + ",A" ;
                    }else if(xdjmlist.get(i) == 10){
                        xdjms = xdjms + ",B";
                    }else if(xdjmlist.get(i) == 11){
                        xdjms = xdjms + ",C";
                    }else {
                        xdjms = xdjms + "," + (xdjmlist.get(i) + 1);
                    }
                }
            }
            obj.setJZSXDJM(xdjms);
            ArrayList<Integer> znlist = zn.getAllItemSelectedIndex();
            String zns = "";
            for (int i = 0; i < znlist.size(); i++) {
                if (i == 0) {
                    zns = (znlist.get(i) + 1) + "";
                }else {
                    if(znlist.get(i) == 9){
                        zns = zns + ",A" ;
                    }else if(znlist.get(i) == 10){
                        zns = zns + ",B";
                    }else if(znlist.get(i) == 11){
                        zns = zns + ",C";
                    }else {
                        zns = zns + "," + (znlist.get(i) + 1);
                    }
                }
            }
            obj.setJZSZN(zns);
            ArrayList<Integer> cjqklist = cjqk.getAllItemSelectedIndex();
            String cjqks = "";
            for (int i = 0; i < cjqklist.size(); i++) {
                if (i == 0) {
                    cjqks = (cjqklist.get(i) + 1) + "";
                }else {
                    cjqks = cjqks + "," + (cjqklist.get(i) + 1);
                }
            }
            obj.setCJQK(cjqks);

            ArrayList<Integer> guanlilist = guanli.getAllItemSelectedIndex();
            String guanlis = "";
            for (int i = 0; i < guanlilist.size(); i++) {
                if(guanlilist.get(i) == 0){
                    guanlis = guanlis + ",LNR" ;
                }else if(guanlilist.get(i) == 1){
                    guanlis = guanlis + ",ET";
                }else if(guanlilist.get(i) == 2){
                    guanlis = guanlis + ",YCF";
                }else  if(guanlilist.get(i) == 3){
                    guanlis = guanlis + ",GXY" ;
                }else if(guanlilist.get(i) == 4){
                    guanlis = guanlis + ",TNB";
                }else if(guanlilist.get(i) == 5){
                    guanlis = guanlis + ",ZXJSJB";
                }else  if(guanlilist.get(i) == 6){
                    guanlis = guanlis + ",GXB" ;
                }else if(guanlilist.get(i) == 7){
                    guanlis = guanlis + ",NCZ";
                }else if(guanlilist.get(i) == 8){
                    guanlis = guanlis + ",CJR";
                }else if(guanlilist.get(i) == 9){
                    guanlis = guanlis + ",FJH";
                }
            }
            if(null != guanlis && !"".equals(guanlis) &&  guanlis.startsWith(",")){
                guanlis = guanlis.substring(1,guanlis.length());
            }
            obj.setGUANLI(guanlis);

            obj.setYCBSMC(ycbmc.getText().toString());
            obj.setJTQKHZ(hzxm.getText().toString());
            obj.setJTQKHZSFZH(hzsfzh.getText().toString());
            obj.setJTQKRKS(jtrks.getText().toString());
            obj.setJTQKJTJG(jtjg.getText().toString());
            obj.setYWGMSQT(gms_qt.getText().toString());
            obj.setPz_record_id(pz_record_id.getText().toString());

            if (NetWorkUtils.isNetworkConnected(con)) {  //////网络存在
                RequestParams ps = new RequestParams();
                /*ps.add("entity.SCJDRQ", obj.getSCJDRQ());*/
                ps.add("entity.XINGMING", obj.getXINGMING());
                ps.add("entity.SFZH", obj.getSFZH());
                ps.add("entity.CSRQ", obj.getCSRQ());
                ps.add("entity.XINGBIE", obj.getXINGBIE());
                ps.add("entity.STATUS", obj.getSTATUS());
                ps.add("entity.SWRQ", obj.getSWRQ());
                ps.add("entity.GZDW", obj.getGZDW());
                ps.add("entity.LXRDH", obj.getLXRDH());
                ps.add("entity.LXDH", obj.getLXDH());
                ps.add("entity.LXRXM", obj.getLXRXM());
                ps.add("entity.CZLX", obj.getCZLX());
                ps.add("entity.HJDZ", obj.getHJDZ());
                ps.add("entity.CZDZ", obj.getCZDZ());
                ps.add("entity.MINZU", obj.getMINZU());
                ps.add("entity.XUEXING", obj.getXUEXING());
                ps.add("entity.XUEXINGRH", obj.getXUEXINGRH());
                ps.add("entity.WHCD", obj.getWHCD());
                ps.add("entity.ZHIYE", obj.getZHIYE());
                ps.add("entity.HYQK", obj.getHYQK());
                ps.add("entity.YLFYZFFS", obj.getYLFYZFFS());
                ps.add("entity.YLFYZFFSQT", obj.getYLFYZFFSQT());
                ps.add("entity.YBKH", obj.getYBKH());
                ps.add("entity.JMKH", obj.getJMKH());
                ps.add("entity.ZGKH", obj.getZGKH());
                ps.add("entity.PKJZKH", obj.getPKJZKH());
                ps.add("entity.YWGMS", obj.getYWGMS());
                ps.add("entity.YWGMSQT", obj.getYWGMSQT());
                ps.add("entity.BLS", obj.getBLS());
                ps.add("entity.JWSJB", obj.getJWSJB());
                ps.add("entity.JWSJBQT", obj.getJWSJBQT());

                ps.add("entity.GXYQZRQ", obj.getGXYQZRQ());
                ps.add("entity.TNBQZRQ", obj.getTNBQZRQ());
                ps.add("entity.GXBQZRQ", obj.getGXBQZRQ());
                ps.add("entity.MXZSXFJBQZRQ", obj.getMXZSXFJBQZRQ());
                ps.add("entity.EXZLQZRQ", obj.getEXZLQZRQ());
                ps.add("entity.NCZQZRQ", obj.getNCZQZRQ());
                ps.add("entity.JSBQZRQ", obj.getJSBQZRQ());
                ps.add("entity.JHBQZRQ", obj.getJHBQZRQ());
                ps.add("entity.GYQZRQ", obj.getGYQZRQ());
                ps.add("entity.CRBQZRQ", obj.getCRBQZRQ());
                ps.add("entity.ZYBQZRQ", obj.getZYBQZRQ());

                ps.add("entity.JWSSS", obj.getJWSSS());
                ps.add("entity.JWSSSMC1", obj.getJWSSSMC1());
                ps.add("entity.JWSSSRQ1", obj.getJWSSSRQ1());
                ps.add("entity.JWSSSMC2", obj.getJWSSSMC2());
                ps.add("entity.JWSSSRQ2", obj.getJWSSSRQ2());
                ps.add("entity.JWSWSMC1", obj.getJWSWSMC1());
                ps.add("entity.JWSWSRQ1", obj.getJWSWSRQ1());
                ps.add("entity.JWSWSMC2", obj.getJWSWSMC2());
                ps.add("entity.JWSWSRQ2", obj.getJWSWSRQ2());
                ps.add("entity.JWSSXYY1", obj.getJWSSXYY1());
                ps.add("entity.JWSSXRQ1", obj.getJWSSXRQ1());
                ps.add("entity.JWSSXYY2", obj.getJWSSXYY2());
                ps.add("entity.JWSSXRQ2", obj.getJWSSXRQ2());
                ps.add("entity.JZSFQ", obj.getJZSFQ());
                ps.add("entity.JZSMQ", obj.getJZSMQ());
                ps.add("entity.JZSXDJM", obj.getJZSXDJM());
                ps.add("entity.JZSZN", obj.getJZSZN());
                ps.add("entity.YCBS", obj.getYCBS());
                ps.add("entity.YCBSMC", obj.getYCBSMC());
                ps.add("entity.CJQK", obj.getCJQK());

                ps.add("entity.JTQKHZ", obj.getJTQKHZ());
                ps.add("entity.JTQKHZSFZH", obj.getJTQKHZSFZH());
                ps.add("entity.JTQKRKS", obj.getJTQKRKS());
                ps.add("entity.JTQKJTJG", obj.getJTQKJTJG());
                ps.add("entity.JTQKJZQK", obj.getJTQKJZQK());

                ps.add("entity.CFPFSS", obj.getCFPFSS());
                ps.add("entity.RLLX", obj.getRLLX());
                ps.add("entity.YINSHUI", obj.getYINSHUI());
                ps.add("entity.CESUO", obj.getCESUO());
                ps.add("entity.QCL", obj.getQCL());
                ps.add("entity.YLDW", xzqh.getText().toString());
                ps.add("entity.GUANLI", obj.getGUANLI());

//                if (!StringUtils.isEmpty(picname)) {
//                    try {
//                        ps.put("img", new File(Environment.getExternalStorageDirectory() + "/" + picname + ".jpg"));
//                    } catch (FileNotFoundException e) {
//                        e.printStackTrace();
//                    }
//                }
                if (getIntent().getStringExtra("type").equals("edit")) {
                    ps.add("entity.CARDNUM", obj.getCARDNUM());
                    url = HttpUrl.EditGrjbxx;
                } else {
                    url = HttpUrl.SaveGrjbxx;
                }
                ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                ps.add("type", "2");
                ps.add("pz_record_id", obj.getPz_record_id());
                ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                    @Override
                    public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                        String content = new String(response);
                        Log.i("个人基本信息保存", content);
                        RetMsg ret = JSON.parseObject(content, RetMsg.class);
                        if (ret.getCode().equals("200")) {
                            MyToastUtil.ShowToast(con, "保存成功");
                        }else{
                            MyToastUtil.ShowToast(con, ret.getInfo());
                        }
//                        List<JuMin> jlist = DataSupport.where("SFZH = ?", obj.getSFZH()).find(JuMin.class);
//                        if (jlist.size() > 0) {
//                            jlist.get(0).delete();
//                            obj.setIsupdate("1");
//                            obj.setQm(picname);
//                            obj.save();
//                        } else {
//                            obj.setIsupdate("1");
//                            obj.setQm(picname);
//                            obj.save();
//                        }
                        finish();
                    }

                    @Override
                    public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
                        MyToastUtil.ShowToast(con, "保存失败");
                    }
                });
            } else {  //////网络不存在
                MyToastUtil.ShowToast(con, "联网失败");
//                List<JuMin> jlist = DataSupport.where("SFZH = ?", obj.getSFZH()).find(JuMin.class);
//                if (jlist.size() > 0) {
//                    jlist.get(0).delete();
//                    obj.setIsupdate("2");
//                    obj.setQm(picname);
//                    obj.save();
//                    MyToastUtil.ShowToast(con, "保存本地成功");
//                    finish();
//                } else {
//                    obj.setIsupdate("2");
//                    obj.setQm(picname);
//                    obj.save();
//                    MyToastUtil.ShowToast(con, "保存本地成功");
//                    finish();
//                }
            }
        }
    }

    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            if (getIntent().getStringExtra("type").equals("edit")) {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "grxxUpload")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getCARDNUM()||"".equals(obj.getCARDNUM()) ? "noid" : obj.getCARDNUM())
                        .putExtra("tabType", "grxx")
                        .putExtra("class", "jm_info_add.class");
                startActivityForResult(intent, 119);
            } else {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "grxxUpload")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getCARDNUM()||"".equals(obj.getCARDNUM()) ? "noid" : obj.getCARDNUM())
                        .putExtra("tabType", "grxx")
                        .putExtra("class", "jm_info_add.class");
                startActivityForResult(intent, 119);
            }
        }
    }
}
